{% extends 'main.html' %}
{% load filetransfers %}
{% block title %}Documentos | {% endblock %}
{% block content %}
{%if user.is_authenticated %}
<div class="content-box"><!-- Start Content Box -->
  <div class="content-box-header">
    <h3>Documents</h3>
    <ul class="content-box-tabs">
      <li><a href="/documentos" class="default-tab">Documents</a></li>
{% for category in CATEGORIES_CHOICES %}
 <li><a href="{% url upload.views.upload_handler cat=category.0 %}" class="default-tab">{{ category.1 }}</a></li>
{% endfor %}
{%if user.is_staff %}
      <li><a href="#tab2">Upload File</a></li>
{% endif %}
    </ul>
    <div class="clear"></div>
  </div> <!-- End .content-box-header -->
				
  <div class="content-box-content">
    <div class="tab-content default-tab" id="tab1"> 

      <table>
      <thead>
      <tr>
      <th>Filename</th>
      <th>Category</th>
      <th>Size</th>
      <th></th>
      {% for upload in uploads %}
      <tr>
        {% url upload.views.download_handler pk=upload.pk as fallback_url %}
        <td><h4><a href="{% firstof upload.file|public_download_url fallback_url %}">{% firstof upload.title 'unnamed' %}</a></h4></td>
        <td>{{ upload.get_category_display }}</td>
        <td><small>({{ upload.file.size|filesizeformat }})<small></td>
        <form method="post" action="{% url upload.views.delete_handler pk=upload.pk %}">
          {% csrf_token %}
          {%if user.is_staff %}
           <td><input type="submit" value="Delete" /></td>
          {% endif %}
        </form>
      </tr>
      {% endfor %}
      </table>
    </div>
  


    <div class="tab-content" id="tab2"> 
      <form action="{{ upload_url }}" method="POST" accept-charset="utf-8" enctype="multipart/form-data">
      {% csrf_token %}
      {% render_upload_data upload_data %}
      <table>{{ form.as_table }}</table>
      <input type="submit" value="Upload" />
      </form>
    </div>
  </div> <!-- End .content-box-content -->
</div> 
{% else %}





{% endif %}
{% endblock %}

